package com.demo.validate;

import java.util.regex.Pattern;

/**
 * url校验
 *
 * @author sdyang
 * @create 2019-01-22 17:26
 **/
public class UrlValidate extends FieldDataValidate {

    @Override
    public boolean check(Object object) {
        String regex = "^([hH][tT]{2}[pP]:/*|[hH][tT]{2}[pP][sS]:/*|[fF][tT][pP]:/*)(([A-Za-z0-9-~]+).)+([A-Za-z0-9-~\\/])+(\\?{0,1}(([A-Za-z0-9-~]+\\={0,1})([A-Za-z0-9-~]*)\\&{0,1})*)$";
        Pattern pattern = Pattern.compile(regex);
        if (pattern.matcher(object.toString()).matches()) {
            return true;
        } else {
            return false;
        }
    }
}
